package test;

import model.Client;
import model.Product;

import services.CreditCardService;
import services.DatabaseService;
import services.MessagingService;
import services.SalesAutomationService;
import services.StorageService;


public class Main 
{
	static SalesAutomationService sas = new SalesAutomationService();
	static DatabaseService dbs = new DatabaseService();
	static CreditCardService ccs = new CreditCardService();
	static StorageService ss = new StorageService();
	static MessagingService mgs = new MessagingService();
	
	public static void main(String[] args)
	{	
		Product product = sas.selectProduct(1);
		if (dbs.consultInventory(product))
		{
			Client client = new Client();
			client.setName("diego");
			client.setClientId(1);
			client.setCreditNumber("123");
			
			if (sas.makePurchase(product, client))
			{
				System.out.println("Purchase made successfully.");
				
				if (ccs.makePayment(client, product.getValue()))
				{
					System.out.println("Payment made successfully.");
					
					if (ss.storeFileCloud(client, product))
					{
						System.out.println("Receipt stored successfully.");
						if (dbs.updateInventory(product))
							System.out.println("Inventory updated successfully");
						else
							System.out.println("Error during inventory update.");
						
						System.out.println(mgs.sendMessage(client, product));
					}
					else
						System.out.println("Error during receipt storage");
				}
				else
					System.out.println("You purchase could not be performed.\nYou do not have sufficient balance to make this purchase.");
			}
			else
				System.out.println("Error during purchasing operation.");
		}
		else
			System.out.println("The selected product is unavailable.");
	}
}